import { useTranslation } from "@/i18n";
import { call_runtime } from "@/utils/call_runtime";
import { CloseOutlined } from "@ant-design/icons";
import { ButtonProps } from "antd";
import React, { useMemo } from "react";
import { TopBarIconButton } from "./TopBarIconButton";

export interface IProps extends ButtonProps {
  ele?: HTMLElement | null;
}
export function CloseButton(props: IProps) {
  const { t } = useTranslation();
  const { ele, className, onClick, ...remain_props } = props;
  const title = useMemo(() => t('common.exit'), [t])
  const icon = <CloseOutlined />
  const on_click = (e: React.MouseEvent<HTMLElement>) => {
    onClick?.(e)
    call_runtime('Quit')
  }
  return (
    <TopBarIconButton
      className={className}
      title={title}
      onClick={on_click}
      {...remain_props}>
      {icon}
    </TopBarIconButton>
  )
}

